package controllers;

import models.Spurningar;
import models.Svor;
import models.User;
import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.Security;
import views.html.index;

import java.util.ArrayList;
import java.util.List;

public class Application extends Controller {

    @Security.Authenticated(Secured.class)
    public static Result index() {
        List<Spurningar> spurning = Spurningar.findInvolving(request().username());

        List<Svor> svor = new ArrayList<Svor>();
        for(Spurningar spurn : spurning)
        {
            svor = Svor.findSpurning(spurn.id);
        }
        return ok(index.render(
                spurning,
                svor,
                User.find.byId(request().username())
        ));
    }
}